﻿using HZU.ZP.Data.Interfaces.Resume;
using HZU.ZP.Data.Models;
using HZU.ZP.Data.Models.Resume;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HZU.ZP.Data.Impl.Resume
{
    public class InformationDao:IInformationDao
    {
        private EFCoreDbContext _context;

        public InformationDao(EFCoreDbContext context)
        {
            _context = context;
        }

        public void AddInformation(Information information)
        {
            _context.Informations.Add(information);
            _context.SaveChanges();
        }

        public void DeleteInformation(int id)
        {
            var information = _context.Informations.FirstOrDefault(e => e.Id == id);
            _context.Informations.Remove(information);
            _context.SaveChanges();
        }

        public Information GetInformation(int applicantid)
        {
            return _context.Informations.FirstOrDefault(e => e.ApplicantId == applicantid);
        }

        public void UpdateInformation(Information information)
        {
            _context.Informations.Update(information);
            _context.SaveChanges();
        }
    }
}
